﻿using Microsoft.AspNetCore.Mvc;
using NewCodeAPI.IServices;
using NewCodeAPI.Models;
using NewCodeAPI.Service;

namespace NewCodeAPI.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class OpenclassController : Controller
    {
        private readonly IOpenclassService _openclassService;

        public OpenclassController(IOpenclassService openclassService)
        {
            _openclassService = openclassService;
        }

        /// <summary>
        /// 添加课程信息
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public MsgInfo AddBase(ClassBegin classBeginCourse)
        {
            return _openclassService.AddClass(classBeginCourse);
        }

        /// <summary>
        /// 修改课程信息
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        public MsgInfo ModifyClass(int del, string remark, ClassBegin classBeginCourse)
        {
            return _openclassService.ModifyClass(del,remark, classBeginCourse);
        }

        /// <summary>
        /// 获取课程信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public List<MsgInfo> GetClassInfo(string remark)
        {
            return _openclassService.GetClassInfo(remark);
        }

        /// <summary>
        /// 删除课程信息
        /// </summary>
        /// <returns></returns>
        [HttpDelete]
        public MsgInfo DeleteClass(int del, string remark)
        {
            return _openclassService.DeleteClass(del, remark);
        }
    }       
}
